﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using FrameEngine;

namespace wpfUI.CommandUI
{
    public class CommandUIOfToolBarButton : Button, ICommandUI
    {
        private ICommand _command = null;

        private Image _image   = new Image();
        /// <summary>
        /// RibbonMenuItem 命令UI
        /// </summary>
        /// <param name="pCommand"></param>
        public CommandUIOfToolBarButton(ICommand pCommand)
        {
            this._command = pCommand;
            pCommand.SetCommandUI(this);
          
            this.Content = _image;

        }


        public ICommand GetCommand()
        {
            return this._command;
        }

        public void SetCaption(string pCaption)
        {
            this.Content = pCaption;
        }

        public void SetCheckedState(bool pIsCheced)
        {
            // this.IsChecked = pIsCheced;
        }

        public void SetEnabledState(bool pIsEnabled)
        {
            this.IsEnabled = pIsEnabled;
        }

        public void SetImageSource(ImageSource pImageSource)
        {
            _image.Source = pImageSource;
        }

        public void SetToolTip(string pToolTip)
        {
            this.ToolTip = pToolTip;
        }

        public void SetVisibleState(bool IsVisible)
        {
            if (IsVisible)
            {
                this.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
        protected override void OnClick()
        {
            base.OnClick();
            _command.OnClick();
        }


    
    }
}
